package com.test.daily.leetcode.y2022.m05.day0524.v04;

import java.util.HashSet;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/5/24 下午 04:46
 * @version: 1.0
 */
public class Solution {
    public static int process(char[] str, int index, HashSet<Integer> lights) {
        if (index == str.length) {
            for (int i = 0; i < str.length; i++) {
                if (str[i] != 'X') {
                    if (!lights.contains(i - 1) && !lights.contains(i) && !lights.contains(i + 1)) {
                        return Integer.MAX_VALUE;
                    }
                }
            }
            return lights.size();
        } else {
            int no = process(str, index + 1, lights);
            int yes = Integer.MAX_VALUE;
            if (str[index] == '.') {
                lights.add(index);
                yes = process(str, index + 1, lights);
                lights.remove(index);
            }
            return Math.min(yes, no);
        }
    }

    public static int min2(String strs) {
        char[] str = strs.toCharArray();
        int lights = 0;
        int i = 0;
        int N = str.length;
        while (i < N) {
            if (i == N) {
                break;
            } else {
                if (str[i] == '.') {
                    lights++;
                } else if (str[i] == 'X') {
                    lights = lights + 2;
                } else {
                    lights = lights + 3;
                }
            }
        }
        return lights;


    }
}
